package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.BaseCardType;
import com.ruoyi.service.IBaseCardTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 证件类型Controller
 * 
 * @author ruoyi
 * @date 2024-05-13
 */
@RestController
@RequestMapping("/webshop/BaseCardType")
public class BaseCardTypeController extends BaseController
{
    @Autowired
    private IBaseCardTypeService baseCardTypeService;

    /**
     * 查询证件类型列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:BaseCardType:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseCardType baseCardType)
    {
        startPage();
        List<BaseCardType> list = baseCardTypeService.selectBaseCardTypeList(baseCardType);
        return getDataTable(list);
    }

    /**
     * 导出证件类型列表
     */
    @PreAuthorize("@ss.hasPermi('webshop:BaseCardType:export')")
    @Log(title = "证件类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseCardType baseCardType)
    {
        List<BaseCardType> list = baseCardTypeService.selectBaseCardTypeList(baseCardType);
        ExcelUtil<BaseCardType> util = new ExcelUtil<BaseCardType>(BaseCardType.class);
        util.exportExcel(response, list, "证件类型数据");
    }

    /**
     * 获取证件类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('webshop:BaseCardType:query')")
    @GetMapping(value = "/{cardTypeId}")
    public AjaxResult getInfo(@PathVariable("cardTypeId") Long cardTypeId)
    {
        return success(baseCardTypeService.selectBaseCardTypeByCardTypeId(cardTypeId));
    }

    /**
     * 新增证件类型
     */
    @PreAuthorize("@ss.hasPermi('webshop:BaseCardType:add')")
    @Log(title = "证件类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseCardType baseCardType)
    {
        return toAjax(baseCardTypeService.insertBaseCardType(baseCardType));
    }

    /**
     * 修改证件类型
     */
    @PreAuthorize("@ss.hasPermi('webshop:BaseCardType:edit')")
    @Log(title = "证件类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseCardType baseCardType)
    {
        return toAjax(baseCardTypeService.updateBaseCardType(baseCardType));
    }

    /**
     * 删除证件类型
     */
    @PreAuthorize("@ss.hasPermi('webshop:BaseCardType:remove')")
    @Log(title = "证件类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cardTypeIds}")
    public AjaxResult remove(@PathVariable Long[] cardTypeIds)
    {
        return toAjax(baseCardTypeService.deleteBaseCardTypeByCardTypeIds(cardTypeIds));
    }
}
